#include <iostream>

int const maxn = 100100;
bool vis[maxn];
int sum_zero[maxn];
int sum_one[maxn];
int n, m, count;

void init()
{
    for (int i = 0; i <= m; i++) vis[i] = false;
}

bool judge(int l, int r)
{
    return (sum_zero[r] - sum_zero[l - 1] <= count);
}

int main()
{
    std::ios::sync_with_stdio(false);
    int T; std::cin >> T;
    while (T--) {
        std::cin >> n >> m;
        init();
        count = 0;
        for (int i = 0, x; i < n; i++) {
            std::cin >> x;
            if (!x) count++;
            else vis[x] = true;
        }

        for (int i = 1; i <= m; i++) {
            sum_zero[i] = sum_zero[i - 1];
            sum_one[i] = sum_one[i - 1];
            if (vis[i]) sum_one[i]++;
            else sum_zero[i]++;
        }
        
        int ans = 0;
        for (int i = 1; i <= m; i++) {
            int l = 1, r = i;
            while (l + 1 < r) {
                int mid = (l + r) / 2;
                if (judge(mid, i)) r = mid;
                else l = mid;
            }
            if (judge(l, i)) r = l;
            ans = std::max(ans, i - r + 1);
        }
        std::cout << ans << '\n';
    }
}

